package org.tgcloud.group.web.controller.manager;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.*;
import org.tgcloud.group.core.APPResultMessage;
import org.tgcloud.group.core.custom.Permissions;
import org.tgcloud.group.core.session.Session;
import org.tgcloud.group.service.manager.MediumOtherProjectManageService;
import org.tgcloud.group.web.controller.dto.medium.AllProjectByYiHuoAndMediumDTO;
import org.tgcloud.group.web.controller.dto.medium.MjMediumOtherProjectDTO;
import org.tgcloud.group.web.controller.req.medium.MediumUserReq;

/**
 * @Author: zhy
 * @Created: 2024-05-29-下午1:17
 * @Description: 媒体-其他项目管理相关接口
 */
@Api(tags = "媒体管理相关接口")
@RestController
@RequestMapping("/manager/pc/user")
@EnableAutoConfiguration
public class MediumOtherProjectManageController extends ManageAPPBaseController {

    @Autowired
    private MediumOtherProjectManageService mediumOtherProjectManageService;


    @Permissions("mediumOtherProject:view")
    @ApiOperation(value = "媒体-其他项目")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/getMediumOtherProjectList", method = RequestMethod.POST)
    public APPResultMessage<Object, MjMediumOtherProjectDTO> getMediumOtherProjectList(@ModelAttribute("session") Session session,
                                                                                       @RequestParam(required = false) Integer pageNum,
                                                                                       @RequestParam(required = false) Integer pageSize,
                                                                                       @RequestParam(required = false) String keyword,
                                                                                       @RequestParam(required = false) Integer otherProjectType){
        return mediumOtherProjectManageService.getMediumOtherProjectList(pageNum, pageSize, keyword, otherProjectType);
    }


    @Permissions("mediumOtherProject:addMediumOtherProject")
    @ApiOperation(value = "媒体-其他项目-新增")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/doAddMediumOtherProject", method = RequestMethod.POST)
    public APPResultMessage doAddMediumOtherProject(@ModelAttribute("session") Session session,
                                                    @RequestParam Integer otherProjectType,
                                                    @RequestParam String projectName,
                                                    @RequestParam String brands,
                                                    @RequestParam(required = false) String remark){
        return mediumOtherProjectManageService.doAddMediumOtherProject(session.getUserId(), otherProjectType, projectName, brands,
                remark);
    }


    @Permissions("mediumOtherProject:editMediumOtherProject")
    @ApiOperation(value = "媒体-其他项目-修改")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/doEditMediumOtherProject", method = RequestMethod.POST)
    public APPResultMessage doEditMediumOtherProject(@ModelAttribute("session") Session session,
                                                    @RequestParam(required = false) Integer otherProjectType,
                                                    @RequestParam(required = false) String projectName,
                                                    @RequestParam(required = false) String brands,
                                                     @RequestParam int id,
                                                     @RequestParam(required = false) String remark){
        return mediumOtherProjectManageService.doEditMediumOtherProject(session.getUserId(), otherProjectType, projectName, brands, id,
                remark);
    }


    @Permissions("mediumOtherProject:delMediumOtherProject")
    @ApiOperation(value = "媒体-其他项目-删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/doDelMediumOtherProject", method = RequestMethod.POST)
    public APPResultMessage doDelMediumOtherProject(@ModelAttribute("session") Session session,
                                                     @RequestParam int id){
        return mediumOtherProjectManageService.doDelMediumOtherProject(session.getUserId(), id);
    }




    @Permissions("mediumOtherProject:addMediumOtherProject")
    @ApiOperation(value = "媒体日历-新增其他项目")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/doAddMediumOtherProjectFromCal", method = RequestMethod.POST)
    public APPResultMessage doAddMediumOtherProjectFromCal(@ModelAttribute("session") Session session,
                                                           @RequestParam(required = false) Integer otherProjectType,
                                                           @RequestParam(required = false) String projectName,
                                                           @RequestParam(required = false) String brands,
                                                           @RequestParam int lineId,
                                                           @RequestParam Long chooseTime,
                                                           @RequestParam(required = false) Integer chooseId,
                                                           @RequestParam(required = false) Integer chooseType,
                                                           @RequestParam(required = false) Integer sureType,
                                                           @RequestParam(required = false) String remark,
                                                           @RequestParam(required = false) Integer endDayNum,
                                                           @RequestParam(required = false) Integer lineIndex,
                                                           @RequestParam(required = false) Integer areaType){
        return mediumOtherProjectManageService.doAddMediumOtherProjectFromCal(session.getUserId(), otherProjectType, projectName, brands,
                lineId, chooseTime, chooseType, chooseId, sureType, remark, endDayNum, lineIndex, areaType);
    }


    @ApiOperation(value = "选择项目-易货项目与媒体的其他项目")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/getAllProjectByYiHuoAndMedium", method = RequestMethod.POST)
    public APPResultMessage<Object, AllProjectByYiHuoAndMediumDTO> getAllProjectByYiHuoAndMedium(@ModelAttribute("session") Session session,
                                                                                                 @RequestParam(required = false) Integer pageNum,
                                                                                                 @RequestParam(required = false) Integer pageSize,
                                                                                                 @RequestParam(required = false) String keyword,
                                                                                                 @RequestParam(required = false) Integer projectType){
        return mediumOtherProjectManageService.getAllProjectByYiHuoAndMedium(pageNum, pageSize, keyword, projectType);
    }




    @Permissions("mediumOtherProject:addMediumOtherProject")
    @ApiOperation(value = "媒体日历-确认待确认的媒体排期")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/doSureMediumOtherProject", method = RequestMethod.POST)
    public APPResultMessage doSureMediumOtherProject(@ModelAttribute("session") Session session,
                                                     @RequestParam Integer chooseId,
                                                     @RequestParam Integer sureType){
        return mediumOtherProjectManageService.doSureMediumOtherProject(session.getUserId(), chooseId, sureType);
    }


    @ApiOperation(value = "媒体日历-删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/doDelProjectMedium", method = RequestMethod.POST)
    public APPResultMessage doDelProjectMedium(@ModelAttribute("session") Session session,
                                                    @RequestParam int id){
        return mediumOtherProjectManageService.doDelProjectMedium(session.getUserId(), id);
    }




    @Permissions("medium:updateUser")
    @ApiOperation(value = "媒体日历-修改排期人")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/doUpdateMediumUser", method = RequestMethod.POST)
    public APPResultMessage doUpdateMediumUser(@ModelAttribute("session") Session session,
                                               @RequestBody MediumUserReq req){
        return mediumOtherProjectManageService.doUpdateMediumUser(session.getUserId(), req);
    }

}
